package com.qijian.maindata.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.qijian.maindata.domain.LineProcess;
import com.qijian.maindata.domain.LineProcessWork;
import com.qijian.maindata.domain.query.LineProcessQuery;
import com.qijian.maindata.domain.vo.LineProcessBomVo;
import com.qijian.maindata.domain.vo.LineProcessVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * 工艺Mapper接口
 *
 * @author qijian
 * @date 2021-09-03
 */
public interface LineProcessMapper extends BaseMapper<LineProcess> {
    @Select("select count(*) from main_line WHERE create_time >= CURRENT_DATE ")
    long countCurrentDateWithDel();

    List<LineProcessVo> selectVo(@Param(Constants.WRAPPER) Wrapper<LineProcessQuery> queryWrapper);

    List<LineProcessVo> selectImageVo(@Param(Constants.WRAPPER) Wrapper<LineProcessQuery> queryWrapper);

    List<LineProcessBomVo> selectProcessAndBomVo(@Param(Constants.WRAPPER) QueryWrapper<LineProcessQuery> invoke);

    List<LineProcessBomVo> selectEcnProcessAndBomVo(@Param("query") LineProcessQuery query, @Param("createStartTime") String createStartTime,
                                                    @Param("createEndTime") String createEndTime, @Param("type") Integer type);

    List<LineProcessBomVo> groupByTypeName(@Param("bomId") Long bomId, @Param("typeName") String typeName, @Param("isOut") Boolean isOut);

    List<LineProcessBomVo> listByTypeName(@Param("bomId") Long bomId, @Param("typeName") String typeName, @Param("isOut") Boolean isOut);

    // 定额申请 数控件整理使用
    List<LineProcessBomVo> listByTypeName4DE(@Param("bomId") Long bomId, @Param("typeName") String typeName,
                                             @Param("isOut") Boolean isOut,
                                             @Param("allowProcessNameList") List<String> allowProcessNameList );
    List<LineProcessVo> getProcessByBomId(Long bomId);

    List<LineProcessBomVo> selectProcessAndBomVoFromQuality(@Param(Constants.WRAPPER) QueryWrapper<LineProcessQuery> invoke);

    List<String> selectAcceptProcessOrder(@Param("processIds") Set processIds);

    int updateProcessByProcessId(Long mainId);
    void updateProcessOrderByDeProcessId(Long mainId);

    void updateProcessOrderFactoryByDeProcessId(Long mainId);

    List<LineProcessWork> listToChangeProcessWork(@Param("processId")Long processId );
}
